<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        var num = 0;
        // while (num < 20) {
        while (num > 0 && num < 20) { // 对比do-while
            num++;
            console.log(num);
        }
    </script>

</body>

</html>

<!-- while语句和do ... while语句 -->
<!-- https://developer.mozilla.org/zh-CN/docs/Learn/JavaScript/Building_blocks/Looping_code#while%E8%AF%AD%E5%8F%A5%E5%92%8Cdo_..._while%E8%AF%AD%E5%8F%A5 -->

<!-- while -->
<!-- https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/while -->